﻿<UserControl x:Class="ModernUILogViewer.Content.ContentSearchFile"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"                
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"                
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:model="clr-namespace:ModernUILogViewer.Model"
             xmlns:business="clr-namespace:ModernUILogViewer.Business"             
             xmlns:conv="clr-namespace:ModernUILogViewer.Converters"
             xmlns:vm="clr-namespace:ModernUILogViewer.ViewModel"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.Resources>
        <mui:NullToVisibilityConverter x:Key="nulltovisconverter" />
        <business:DataContextSpy x:Key="spy" />
        <DataTemplate DataType="{x:Type vm:FileViewModel}">
            <DataTemplate.Resources>
                <conv:ConverterChain x:Key="filenameconverter">                    
                    <conv:FilenameConverter />
                    <mui:ToUpperConverter />
                </conv:ConverterChain>
            </DataTemplate.Resources>
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding IsSelected}" >
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Checked" >
                            <i:InvokeCommandAction Command="{Binding Source={StaticResource spy}, Path=DataContext.FilterLogEntries}" />
                        </i:EventTrigger>
                        <i:EventTrigger EventName="Unchecked">
                            <i:InvokeCommandAction Command="{Binding Source={StaticResource spy}, Path=DataContext.FilterLogEntries}" />
                        </i:EventTrigger>
                        <i:EventTrigger EventName="MouseRightButtonDown" >
                            <i:InvokeCommandAction Command="{Binding Source={StaticResource spy}, Path=DataContext.ExlusiveSelectFile}" CommandParameter="{Binding}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </CheckBox>
                <TextBlock Text="{Binding Path=Filename, Converter={StaticResource filenameconverter}}" />
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>

    <Grid>
        <StackPanel>
            <ListBox Margin="5, 10, 0, 0" ItemsSource="{Binding ListFiles}" />

            <TextBlock FontSize="{StaticResource SmallFontSize}" Margin="0, 15, 0, 0">
                <TextBlock.Resources>                    
                    <conv:NullToBooleanConverter x:Key="nulltobooleanconverter" />
                </TextBlock.Resources>
                <TextBlock.Style>
                    <Style TargetType="{x:Type TextBlock}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ListFiles}" Value="{x:Null}">
                                <Setter Property="Text" Value="No files loaded" />                                
                            </DataTrigger>
                            <DataTrigger Binding="{Binding ListFiles, Converter={StaticResource nulltobooleanconverter}}" Value="True">
                                <Setter Property="Text" Value="* Right click to select only one file" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style>
                
            </TextBlock>
        </StackPanel>
    </Grid>
</UserControl>
